/*
 * $Id: BaseResponseBuilder.java 51 2013-06-28 16:13:44Z gabakyan $
 * $Author: gabakyan $
 * $Revision: 51 $
 * $Date: 2013-06-28 16:13:44 +0000 (Fri, 28 Jun 2013) $
 *
 * Copyright (c) 2013 Supply Chain Intelligence (SCI), Inc.
 * http://www.scintelligence.com/, Email: info@scintelligence.com
 * All rights reserved.
 *
 * This file is part of Logistics Map.
 *
 * Logistics Map is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * Logistics Map is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Logistics Map.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.sci.logisticsmap.service.support.builder.response;

import com.sci.logisticsmap.support.builder.Builder;
import com.sci.logisticsmap.support.model.ResponseStatus;
import com.sci.logisticsmap.support.model.ResponseWrapper;

import java.io.Serializable;

/**
 * The class {@code BaseResponseBuilder} represents the base class for response building.
 *
 * @author gabakyan@gmail.com (Last modified by $Author: gabakyan $)
 * @version $Revision: 51 $
 */
public abstract class BaseResponseBuilder<Content extends Serializable> implements Builder<Content> {
    /*
     * (non-Javadoc)
     *
     * @see com.sci.logisticsmap.support.builder.BaseBuilder#build()
     */
    public abstract Content build();

    /**
     * Builds the target response wrapper.
     *
     * @return The built target response wrapper.
     */
    public final ResponseWrapper<Content> buildWrapper() {
        return buildWrapper(ResponseStatus.OK, null);
    }

    /**
     * Builds the target response wrapper.
     *
     * @param status The status.
     *
     * @return The built target response wrapper.
     */
    public final ResponseWrapper<Content> buildWrapper(int status) {
        return buildWrapper(status, null);
    }

    /**
     * Builds the target response wrapper.
     *
     * @param message The message.
     *
     * @return The built target response wrapper.
     */
    public final ResponseWrapper<Content> buildWrapper(String message) {
        return buildWrapper(ResponseStatus.OK, message);
    }

    /**
     * Builds the target response wrapper.
     *
     * @param status The status.
     * @param message The message.
     *
     * @return The built target response wrapper.
     */
    public final ResponseWrapper<Content> buildWrapper(int status, String message) {
        ResponseWrapper<Content> responseWrapper = new ResponseWrapper<Content>();
        responseWrapper.setStatus(status);
        responseWrapper.setMessage(message);
        responseWrapper.setContent(build());
        return responseWrapper;
    }
}
